#ifndef XL_UPLOADER_FILE_LIST_VIEW_CTRL_H
#define XL_UPLOADER_FILE_LIST_VIEW_CTRL_H
#include <atlstr.h>
#include <atltypes.h>
#include <atlbase.h>
#include <atlapp.h>
#include <atlwin.h>
#include <atlctrls.h>

#include "xDocument.h"
#include "FileInfo.h"
#include "SystemImageList.h"


//////////////////////////////////////////////////////////////////////////
// interface
class IFileListViewCtrlParent {
public:
	virtual CRect getFileListViewCtrlRect() = 0;
	virtual UINT getFileListViewCtrlId() = 0;
	virtual HWND getFileListViewCtrlParentHwnd() = 0;
	virtual CxDocument* getDocument() = 0;
};

class CFileListViewCtrl
	: public CListViewCtrl
	, public CxDocument::IObserver
{
	IFileListViewCtrlParent       *m_pWndParent;
	CSystemImageList               m_sysImgList;

	int _GetIndexById(FileInfo::ID);

public:
	CFileListViewCtrl(IFileListViewCtrlParent *pWndParent);
	virtual ~CFileListViewCtrl(void);

	HWND createWindow();
	void adjustColumnWidth();

	bool insertFile (const FileInfo &fi);
	void updateFile (FileInfo::ID id);
	// FileInfo::ID getSelectedID();
	FileInfo::ID getIdFromItem(int iItem);

	void clear();

	//////////////////////////////////////////////////////////////////////////
	// owner draw related
	void drawItem (DRAWITEMSTRUCT *);
	void measureItem (WPARAM, LPARAM);

	//////////////////////////////////////////////////////////////////////////
	// virtual 
	virtual void onEvent(CxDocument::IObserver::EVT evt, void *param);
};

#endif
